//
// Created by xili on 2024/9/18 19:18.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int matchPlayersAndTrainers(vector<int> &players, vector<int> &trainers) {
        ranges::sort(players);
        ranges::sort(trainers);
        int n = players.size();
        int m = trainers.size();
        int j = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            while (j < m && players[i] > trainers[j]) {
                j++;
            }
            if (j == m) {
                break;
            }
            ans++;
            j++;
        }
        return ans;
    }
};